{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "3xW4O0zuKfWD"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "from openai import OpenAI\n",
        "import rich\n",
        "from google.colab import userdata\n",
        "from google.colab import drive"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "api_key = userdata.get('OPENAI_API_KEY')\n",
        "MODEL = \"gpt-4o-mini\"\n",
        "\n",
        "openai = OpenAI(api_key=api_key)"
      ],
      "metadata": {
        "id": "vUydnLeLKs03"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "**Sending PDF file as input prompt and generating response based on the data inside PDF**"
      ],
      "metadata": {
        "id": "blCx6gu1Vl46"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Uploading file is same in both Chat and Responses API"
      ],
      "metadata": {
        "id": "nznKPApuXC9z"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Upload image in your googld drive\n",
        "# Connect this Colab to my Google Drive\n",
        "# It will ask permissions to connect your google drive with colab\n",
        "\n",
        "drive.mount(\"/content/drive\")\n",
        "file_path = \"/content/drive/MyDrive/Temp/Panaversity-Certified-Agentic-and-Robotic-AI-Engineer.pdf\""
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "HQzzbkUkRafR",
        "outputId": "d3c10e71-6366-4138-c8f2-50e1e86c2b4e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "file = openai.files.create(\n",
        "    file=open(file_path, \"rb\"),\n",
        "    purpose=\"user_data\"\n",
        ")"
      ],
      "metadata": {
        "id": "qvJhp-k5XEmW"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# This will list all the files in your OpenAI's account\n",
        "list = openai.files.list()\n",
        "rich.print(list)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "zgxv-xFtQe1s",
        "outputId": "77036534-7669-44a6-feae-a6d39ed5ce41"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "SyncCursorPage\u001b[1m[\u001b[0mFileObject\u001b[1m]\u001b[0m\u001b[1m(\u001b[0m\n",
              "    \u001b[33mdata\u001b[0m=\u001b[1m[\u001b[0m\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-XFZ7G2HBPCmnhzwdoRJGVF'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m1407011\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1742958355\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'Panaversity-Certified-Agentic-and-Robotic-AI-Engineer.pdf'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'user_data'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m,\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-8kai7amHc4aJ55jZ7Fx9xJ'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m8573289\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1742538897\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'deep_research_blog.pdf'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'assistants'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m,\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-Fh7ULskzHk4v4iGC1RTrmv'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m1407011\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1742470264\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'Panaversity-Certified-Agentic-and-Robotic-AI-Engineer.pdf'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'user_data'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m,\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-41Hj591JeuryyJSPm5GMNC'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m5956\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1740988395\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'step_metrics.csv'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'fine-tune-results'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m,\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-U1HVB2Pnm5bnvgoqpYahzJ'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m47085\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1740985592\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'fine_tune_validation.jsonl'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'fine-tune'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m,\n",
              "        \u001b[1;35mFileObject\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mid\u001b[0m=\u001b[32m'file-32nJjb77b9QPcwNsF4KuTo'\u001b[0m,\n",
              "            \u001b[33mbytes\u001b[0m=\u001b[1;36m188742\u001b[0m,\n",
              "            \u001b[33mcreated_at\u001b[0m=\u001b[1;36m1740985573\u001b[0m,\n",
              "            \u001b[33mfilename\u001b[0m=\u001b[32m'fine_tune_train.jsonl'\u001b[0m,\n",
              "            \u001b[33mobject\u001b[0m=\u001b[32m'file'\u001b[0m,\n",
              "            \u001b[33mpurpose\u001b[0m=\u001b[32m'fine-tune'\u001b[0m,\n",
              "            \u001b[33mstatus\u001b[0m=\u001b[32m'processed'\u001b[0m,\n",
              "            \u001b[33mexpires_at\u001b[0m=\u001b[3;35mNone\u001b[0m,\n",
              "            \u001b[33mstatus_details\u001b[0m=\u001b[3;35mNone\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m]\u001b[0m,\n",
              "    \u001b[33mhas_more\u001b[0m=\u001b[3;91mFalse\u001b[0m,\n",
              "    \u001b[33mobject\u001b[0m=\u001b[32m'list'\u001b[0m,\n",
              "    \u001b[33mfirst_id\u001b[0m=\u001b[32m'file-XFZ7G2HBPCmnhzwdoRJGVF'\u001b[0m,\n",
              "    \u001b[33mlast_id\u001b[0m=\u001b[32m'file-32nJjb77b9QPcwNsF4KuTo'\u001b[0m\n",
              "\u001b[1m)\u001b[0m\n"
            ],
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">SyncCursorPage<span style=\"font-weight: bold\">[</span>FileObject<span style=\"font-weight: bold\">](</span>\n",
              "    <span style=\"color: #808000; text-decoration-color: #808000\">data</span>=<span style=\"font-weight: bold\">[</span>\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-XFZ7G2HBPCmnhzwdoRJGVF'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1407011</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1742958355</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Panaversity-Certified-Agentic-and-Robotic-AI-Engineer.pdf'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'user_data'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>,\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-8kai7amHc4aJ55jZ7Fx9xJ'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">8573289</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1742538897</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'deep_research_blog.pdf'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'assistants'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>,\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-Fh7ULskzHk4v4iGC1RTrmv'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1407011</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1742470264</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Panaversity-Certified-Agentic-and-Robotic-AI-Engineer.pdf'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'user_data'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>,\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-41Hj591JeuryyJSPm5GMNC'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">5956</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1740988395</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'step_metrics.csv'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fine-tune-results'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>,\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-U1HVB2Pnm5bnvgoqpYahzJ'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">47085</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1740985592</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fine_tune_validation.jsonl'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fine-tune'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>,\n",
              "        <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">FileObject</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-32nJjb77b9QPcwNsF4KuTo'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">bytes</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">188742</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">created_at</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1740985573</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">filename</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fine_tune_train.jsonl'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">purpose</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'fine-tune'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'processed'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">expires_at</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">status_details</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">]</span>,\n",
              "    <span style=\"color: #808000; text-decoration-color: #808000\">has_more</span>=<span style=\"color: #ff0000; text-decoration-color: #ff0000; font-style: italic\">False</span>,\n",
              "    <span style=\"color: #808000; text-decoration-color: #808000\">object</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'list'</span>,\n",
              "    <span style=\"color: #808000; text-decoration-color: #808000\">first_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-XFZ7G2HBPCmnhzwdoRJGVF'</span>,\n",
              "    <span style=\"color: #808000; text-decoration-color: #808000\">last_id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'file-32nJjb77b9QPcwNsF4KuTo'</span>\n",
              "<span style=\"font-weight: bold\">)</span>\n",
              "</pre>\n"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Chat Completion API\n",
        "\n",
        "https://platform.openai.com/docs/guides/pdf-files?api-mode=chat"
      ],
      "metadata": {
        "id": "5wlqKfVBKyjD"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "response = openai.chat.completions.create(\n",
        "    model= MODEL,\n",
        "    messages=[\n",
        "        {\n",
        "            \"role\": \"user\",\n",
        "            \"content\": [\n",
        "                {\n",
        "                    \"type\": \"file\",\n",
        "                    \"file\": {\n",
        "                        \"file_id\": file.id,\n",
        "                    }\n",
        "                },\n",
        "                {\n",
        "                    \"type\": \"text\",\n",
        "                    \"text\": \"How many modules or quaraters are there in this course?\",\n",
        "                },\n",
        "            ]\n",
        "        }\n",
        "    ]\n",
        ")\n",
        "\n",
        "print(response.choices[0].message.content)"
      ],
      "metadata": {
        "id": "dBrUkMCUKz0s",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "e8c0c9aa-f866-4624-b6dd-797127e56716"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The course is divided into two levels: core and professional. The core program is structured to be completed in one year if you take one course at a time, and it comprises multiple modules.\n",
            "\n",
            "1. **Core Level** - Includes multiple modules, starting from AI-101 to AI-202.\n",
            "2. **Professional Level** - Further modules from AI-301 to AI-501, plus optional specializations.\n",
            "\n",
            "To give a clearer overview:\n",
            "- **Core Level Modules:** Approximately 6-7 foundational courses.\n",
            "- **Professional Level Modules:** Several advanced courses, including AI-451 through AI-501.\n",
            "\n",
            "Overall, it seems the entire program consists of about 12 to 15 core and professional modules, plus optional specialization modules.\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Responses API\n",
        "\n",
        "https://platform.openai.com/docs/guides/pdf-files?api-mode=responses"
      ],
      "metadata": {
        "id": "tCzSosP5K-JR"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "response = openai.responses.create(\n",
        "    model=\"gpt-4o\",\n",
        "    input=[\n",
        "        {\n",
        "            \"role\": \"user\",\n",
        "            \"content\": [\n",
        "                {\n",
        "                    # Type is different here, all the inputs are like input_text, input_file, input_image in responses API\n",
        "                    \"type\": \"input_file\",\n",
        "                    # No file object here, just the file_id\n",
        "                    \"file_id\": file.id,\n",
        "                },\n",
        "                {\n",
        "                    \"type\": \"input_text\",\n",
        "                    \"text\": \"Analyze the AI-201\",\n",
        "                },\n",
        "            ]\n",
        "        }\n",
        "    ]\n",
        ")\n",
        "\n",
        "print(response.output_text)"
      ],
      "metadata": {
        "id": "gUjC_PQCcETm",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "a4581212-3f7f-4a22-de12-2c2017a3ed2e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "The AI-201 course, \"Fundamentals of Agentic AI - From Foundations to Autonomous Agents,\" provides a comprehensive introduction to Agentic AI by focusing on developing autonomous, intelligent systems. Here's a breakdown of its key components and learning objectives:\n",
            "\n",
            "### Course Focus:\n",
            "- **Introduction to Agentic AI**: The course starts by establishing a strong understanding of Conversational and Generative AI, which are essential building blocks for Agentic AI.\n",
            "- **Practical Application**: Emphasizes hands-on skill development using the OpenAI Agents SDK.\n",
            "- **AgentOps Fundamentals**: Covers basic aspects of deploying and monitoring AI agents.\n",
            "\n",
            "### Key Learning Modules:\n",
            "\n",
            "1. **Foundations of Intelligent AI**:\n",
            "   - Differentiate between Conversational and Generative AI.\n",
            "   - Understand their strengths and how they lay the groundwork for Agentic AI.\n",
            "\n",
            "2. **Conversational AI Development**:\n",
            "   - Engage in building dialogue-based AI systems.\n",
            "   - Focus on human-AI interaction and prompt engineering.\n",
            "\n",
            "3. **Agentic Design Patterns**:\n",
            "   - Explore common design patterns for autonomous agents.\n",
            "   - Learn about task decomposition, memory management, and tool usage.\n",
            "\n",
            "4. **OpenAI Agents SDK Mastery**:\n",
            "   - Leverage OpenAI Agents SDK to develop autonomous agents with minimal human intervention.\n",
            "   - Solidify skills through hands-on projects.\n",
            "\n",
            "5. **Building Augmented LLMs**:\n",
            "   - Construct and deploy Model Context Protocol (MCP) Servers and Agentic Clients.\n",
            "   - Enhance capabilities of standard Large Language Models.\n",
            "\n",
            "6. **AgentOps Fundamentals**:\n",
            "   - Introduction to agent deployment, lifecycle management, and basic monitoring.\n",
            "   - Discuss challenges and best practices for managing agent-based systems.\n",
            "\n",
            "7. **Agentic Payments & Future Applications**:\n",
            "   - Explore the intersection of Agentic AI and financial systems.\n",
            "   - Investigate potential for AI agents in payment processing and commerce.\n",
            "\n",
            "### Course Outcomes:\n",
            "\n",
            "Upon completion, students will be able to:\n",
            "- Articulate foundational principles of Conversational, Generative, and Agentic AI.\n",
            "- Design, develop, and deploy practical conversational AI systems.\n",
            "- Implement Agentic Design Patterns using the OpenAI Agents SDK.\n",
            "- Build autonomous AI agents capable of performing complex tasks.\n",
            "- Utilize MCP Servers and Agentic Clients to augment LLMs.\n",
            "- Understand AgentOps concepts in real-world deployments.\n",
            "- Explore potential applications of Agentic Payments.\n",
            "\n",
            "### Prerequisite:\n",
            "- Completion of AI-101: Modern AI Python Programming.\n",
            "\n",
            "### Learning Approach:\n",
            "- Emphasizes progressive pedagogical strategies.\n",
            "- Utilizes hands-on projects to reinforce learning.\n",
            "\n",
            "This course is designed to equip students with the foundational skills necessary to develop and deploy autonomous AI systems, preparing them for more advanced studies in Agentic AI.\n"
          ]
        }
      ]
    }
  ]
}